﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// This user controls encapsulates a TextBox along with its required field validator
/// I gives access to manipulating the RequiredFeildValidator as well as the TextBox.
/// It is designed to meet the need for different uses in a web form. This will help 
/// keep code tidy and encapsulated in the right place.
/// </summary>
public partial class DataEntryControls_SimpleTextBox : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    /// <summary>
    /// Text property for the TextBox
    /// </summary>
    public string Text
    {
        get { return this.TextBox1.Text; }
        set { this.TextBox1.Text = value; }
    }

    /// <summary>
    /// Width of the TextBox
    /// </summary>
    public string Width
    {
        get { return this.TextBox1.Width.Value.ToString(); }
        set { this.TextBox1.Width = new Unit(value); }
    }

    /// <summary>
    /// This field activates and deactivates the required field option, by hiding the validotor on the server side
    /// </summary>
    public bool IsRequired
    {
        get { return this.RequiredFieldValidator1.Visible; }
        set { this.RequiredFieldValidator1.Visible = value; }
    }

    /// <summary>
    /// Gives Access to the error message displayed by the validator
    /// </summary>
    public string ErrorMessage
    {
        get { return this.RequiredFieldValidator1.ErrorMessage; }
        set { this.RequiredFieldValidator1.ErrorMessage = value; }
    }

    /// <summary>
    /// Sets the display of the RequiredFieldValidator to dynamic or static.
    /// </summary>
    public ValidatorDisplay Display
    {
        get { return this.RequiredFieldValidator1.Display; }
        set { this.RequiredFieldValidator1.Display = value; }
    }

}
